//
//  ORMianViewController.m
//  News
//
//  Created by rimi on 2016/12/5.
//  Copyright © 2016年 dongfumei. All rights reserved.
//

#import "ORMianViewController.h"
#import "ORMyViewController.h"
#import "ORPageViewController.h"
#import "ORHomeViewController.h"
#import "ORStartPageView.h"

@interface ORMianViewController ()

@property (nonatomic, strong) ORStartPageView *starView;
@property(nonatomic, strong) NSMutableArray<UIViewController *> *childVCs;

@end

@implementation ORMianViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeDataSource];
    
    _starView = [[ORStartPageView alloc]initWithFrame:self.view.bounds];
    _starView.backgroundColor = [UIColor purpleColor];
    [_starView.experienceBtn addTarget:self action:@selector(withClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.starView];
}

-(void)withClick{
    [self.starView removeFromSuperview];
}

-(void)initializeDataSource{
    
    
    self.tabBar.tintColor = [UIColor whiteColor];
    
    [self setupOneChildViewController:[[ORHomeViewController alloc]init] title:@"首页" image:@"首页" tag:0];
    
    [self setupOneChildViewController:[[ORPageViewController alloc]init] title:@"分类" image:@"分类" tag:1];
    
    [self setupOneChildViewController:[ORMyViewController alloc] title:@"我的" image:@"我的" tag:2];
    
    self.tabBar.translucent = NO;
    self.tabBar.barTintColor = MainColor;
    
}

-(void)setupOneChildViewController:(UIViewController *)viewController title:(NSString *)title image:(NSString *)image tag:(NSInteger)tag{
    
    UINavigationController *navc = [[UINavigationController alloc] initWithRootViewController:viewController];
    navc.tabBarItem = [[UITabBarItem alloc]initWithTitle:title image:nil tag:tag];
    navc.navigationBar.barTintColor = MainColor;
    navc.navigationBar.titleTextAttributes = @{NSFontAttributeName: AAFont(20),NSForegroundColorAttributeName:[UIColor whiteColor]};
    navc.navigationBar.tintColor = [UIColor whiteColor];
    
    viewController.tabBarItem.title = title;
    viewController.tabBarItem.image = [UIImage imageNamed:image];
    [self addChildViewController:navc];
    // 设置导航栏不透明（图片从0，64开始放置）
    navc.navigationBar.translucent = NO;
    
}



@end
